<?php

namespace App\Module\Api\Controllers;
use App\Exceptions\Customize\ParamsException;
use App\Module\Api\Controllers\Request\UserDetailsRequest;
use App\Module\Api\Validator\UserDetailsValidator;
use App\System\Base\Services\TokenService;
use App\System\Cis\Repositories\CisUserRepository;

/**
 * Class UserDetailsController 用户详细
 * @package App\Module\Admin\Controllers
 */
class UserDetailsController extends Controller
{

    public function __construct()
    {
        $this->query = new UserDetailsRequest();
        parent::__construct();

    }

    public function index()
    {
        (new UserDetailsValidator())->check();
        $user_id = checkSession();
        $user = CisUserRepository::getInstance();
        $userInfo=$user->getUserById($user_id);
        $data = [
            'id'=>$userInfo->id,
            'avatarPath'=>$userInfo->avatar_path,
            'name'=>$userInfo->name,
            'sex'=>$userInfo->sex,
            'industry'=>$userInfo->industry,
            'statCourse'=>$userInfo->statCourse,
            'statActive'=>$userInfo->statActive,
            'scholarship'=>$userInfo->scholarship,
            'userLevel'=>['levelId'=>$userInfo->level_id,'levelName'=>$userInfo->levelName],
            'region'=>['id'=>$userInfo->region_id,'name'=>$userInfo->regionName]
        ];
        return apiResponse(['userInfo'=>$data]);
    }
}
